草庐IT

iOS Category 继承来封装 NSJSONSerialization

全部标签

c# - DebuggerStepThrough 是否可以继承到自动生成的 IEnumerable 实现中?

DebuggerStepThrough属性允许您跳过进入某些方法/类/属性的步骤。在DebuggerStepThroughbeingignored澄清了c#编译器不会将此属性继承到编译器生成的IEnumerable执行。这种失败的一个简单例子是:staticvoidMain(string[]args){vara=SkipMe().ToList();}[System.Diagnostics.DebuggerStepThrough]staticIEnumerableSkipMe(){//commentoutlinebelowandthethrowwillbesteppedover.yiel

c# - 为什么值类型继承自引用类型?

这个问题在这里已经有了答案:HowdoValueTypesderivefromObject(ReferenceType)andstillbeValueTypes?(6个答案)System.ValueTypeUnderstanding(7个答案)关闭7年前。我有两个问题:我们知道所有类型都派生自Object,它是一个引用类型。我的问题是为什么int-这是一个value类型-继承自引用类型Object?这可能吗?如果int派生自Object,为什么我们在将int传递给需要的函数时需要装箱对象作为参数?通常,当您需要将派生类型的对象作为参数传递给期望基类型对象的函数时,使用引用,您不需要做任

c# - 从抽象类引用继承的 EntitySet 的 dapper PropInfo Setter 为 null

我正在尝试用一些简洁的查询替换令人讨厌的LINQ2SQL命中以提高性能。这样做时,我必须将一堆不同的对象编织在一起,以创建保存ASN信息所需的所有信息所需的大对象。我目前遇到的问题是抽象类Orders,该类由两个单独的类AutionOrder和MerchantOrder使用鉴别器属性实现。由于我无法使用dapper创建抽象类对象,因此我改用其中一个公共(public)类。但是,当它构建对象时,它在GetSettableProps内部失败,它找到了正确的DeclaringType但是GetProperty方法在它返回null时正在寻找internal或EntitySet的属性。我尝试使用

c# - 接口(interface)继承多个接口(interface) : how is this handled by a C# compiler?

最近我发现C#允许Aninterfacecaninheritfromoneormorebaseinterfaces.例如,Caliburn.Micro中的IScreen在http://caliburnmicro.codeplex.com/SourceControl/latest#src/Caliburn.Micro/IScreen.cs中执行此操作namespaceCaliburn.Micro{publicinterfaceIScreen:IHaveDisplayName,IActivate,IDeactivate,IGuardClose,INotifyPropertyChangedE

c# - 将接口(interface)转换为它不继承的另一个接口(interface)

我希望这里有人可以解释我所做的错误假设。在C#4.0中,我有2个接口(interface)和一个实现它们的类。在一个方法中,我声明了一个具有第一个接口(interface)类型的变量,使用实现这两个接口(interface)的类实例化它,并且可以以某种方式成功地将它转换为第二个接口(interface),如以下代码所示:publicinterfaceIFirstInterface{voidMethod1();}publicinterfaceISecondInterface{voidMethod2();}publicclassInterfaceImplementation:IFirstI

c# - 泛型与继承(当不涉及集合类时)

这是thisquestion的扩展甚至可能是其他一些问题的重复(如果是这样,请原谅我)。我seefromMSDN泛型通常与集合一起使用Themostcommonuseforgenericclassesiswithcollectionslikelinkedlists,hashtables,stacks,queues,treesandsoonwhereoperationssuchasaddingandremovingitemsfromthecollectionareperformedinmuchthesamewayregardlessofthetypeofdatabeingstored.我

c# - AutoMapper——继承映射不​​工作,相同的源,多个目的地

我可以在AutoMapper(v2.2)中对源类型相同但目标类型不同的映射使用继承映射吗?我有这样的基本情况(真正的类有更多的属性):publicabstractclassBaseViewModel{publicintCommonProperty{get;set;}}publicclassViewModelA:BaseViewModel{publicintPropertyA{get;set;}}publicclassViewModelB:BaseViewModel{publicintPropertyB{get;set;}}ViewModelA和ViewModelB是同一实体类的不同表示

C# 向 COM 公开 - 接口(interface)继承

假设我有一个实现IBaseClass的类BaseClass然后我有一个继承IBaseClass的接口(interface)IClass。然后我有一个名为class的类,它实现了IClass。例如:[ComVisible(true),InterfaceType(ComInterfaceType.IsDual),Guid("XXXXXXX")]publicinterfaceIBaseClass{[PreserveSig]stringGetA()}[ComVisible(true),InterfaceType(ComInterfaceType.IsDual),Guid("XXXXXXX")]

c# - 条件运算符不适用于继承相同基类型的两种类型

为什么条件运算符(?:)在与从单个基类型继承的两个类型一起使用时不起作用?我的例子是:ActionResultfoo=(someCondition)?RedirectToAction("Foo","Bar"):Redirect(someUrl);长格式工作正常的地方:ActionResultfoo;if(someCondition){foo=RedirectToAction("Foo","Bar");}else{foo=Redirect(someUrl);}RedirectToRouteResult和RedirectResult这两个返回类型都继承自ActionResult。

c# - 在 WebApi 中如何在 Controller 类级别继承路由前缀?

请注意,我已经阅读了作为WebApi2.2的一部分的新路由功能,以允许路由继承。但是,这似乎并没有解决我的特定问题。它似乎解决了继承Action级别路由属性的问题,但没有解决在类级别定义的路由前缀。http://www.asp.net/web-api/overview/releases/whats-new-in-aspnet-web-api-22#ARI我想做这样的事情:[RoutePrefix("account")]publicabstractclassAccountControllerBase:ControllerBase{}[RoutePrefix("facebook")]pub